<?php
class Db{
    private static $_obj = null;
    private $_conn = null;
    public function __construct() {
        $config = ROOT.'app'.OSDS.'system'.OSDS.'Db.ini.php';
        if(file_exists($config)&& is_readable($config)){
            $config = parse_ini_file($config);
            $conn = 'mysql:host='.$config['HOST'].';dbname='.$config['DATABASE'];
            $usr = $config['USER'];
            $pwd = $config['PASSWORD'];
            try{
                $this->_conn = new PDO($conn, $usr, $pwd);
            }  catch (Exception $ex){
                die('OEPS... DATABASEVERBINDING GEFAALD');
            }
        }else{
            die('FATALE FOUT... database config');
        }
    }
    public static function conn(){
        if(!self::$_obj instanceof self){
            self::$_obj = new self();
        }
        return self::$_obj->_conn;
    }
}

